#include "InitialPosition.h"


#include "TrajSimul.h"

#include <cmath>

InitialPosition::InitialPosition(Clock clock,Output output,Pulse *field,Pulse *current,MultiLayer multiLayer,NewParameters params)
{
  MultiLayer temp=multiLayer;
  double angle;
  double tempI=current->getLevel(Clock(params).getTimeStamp());

  output.setSave(false);
  current->setLevel(0);
  temp=TrajSimul().solve(clock,output,field,current,multiLayer,params);
  angle=acos(temp[multiLayer.getSolveLayer()].getMag().getZ());
  angle+=params.getSample()[multiLayer.getSolveLayer()]["initialAngle"]*M_PI/180;
  current->setLevel(tempI);
  output.setSave(true);
  x=0;
  y=sin(angle);
  z=cos(angle); 
}

InitialPosition::~InitialPosition()
{

}
